home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 7_10.lha / 7_10 / p_sleep.c < prev    next >
Text File  |  1993-08-08  |  770b  |  29 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. include <process.h>
  6. include <debug.h>    /* DELETE */
  7. / delay for a given amount of pseudo-time
  8. oid process::sleep(unsigned long t)
  9.  
  10.    if (debug) /*DELETE*/ cerr << "process" << this << "::sleep(" << t << ")\n";
  11.    if (debug) /*DELETE*/ cerr << "\tt_curtime == " << t_curtime << "\n";
  12.    if (mustrecurse())
  13.        sleep(t);
  14.  
  15.    else
  16. {
  17. // remove this from other lists
  18. // and place back on run queue
  19. // ordered by new desired time
  20. wakeup(t);
  21.  
  22. // save and schedule another process
  23. if (t_thisprocess == this)
  24.     if (!contextswitch())
  25.     schedule();
  26. if (debug) /*DELETE*/ cerr << "<<<< process" << this << "::sleep(" << t << ")\n";
  27. }
  28.  
  29.